<?php

/**
 * Author: ryu
 *
 * @email:    mo5467@126.com
 * @date      2020-04-25 13:40:07
 * @lastTime: 2020-04-25 23:24:22
 */

namespace Design\Behavioral\ChainOfResponsibilities;

use Psr\Http\Message\RequestInterface;

class FastResponse extends Handler
{

    private $data = [];


    public function __construct(array $data, $succesor=null)
    {
        parent::__construct($succesor);
        $this->data = $data;

    }//end __construct()


    protected function processing(RequestInterface $request)
    {
        $key = sprintf(
            '%s?%s',
            $request->getUri()->getPath(),
            $request->getUri()->getQuery()
        );

        if ($request->getMethod() === 'GET' && isset($this->data[$key]) === true) {
            return $this->data[$key];
        }

        return null;

    }//end processing()


}//end class
